<template>
  <div>
    <el-button type="primary" @click="add">添加</el-button>
    <list-vue  :info="info" :arr="arr" @init="getList" @willUpdate="willUpdate"></list-vue>
    <form-vue :info="info" :arr="arr" @init="getList" ref="form"></form-vue>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { reqrolelist } from "../../http/api";
import formVue from './components/form.vue'
import listVue from './components/list.vue'
export default {
  components:{
    formVue,
    listVue
  },
  data() {
    return {
      info:{
        isshow:false,
        isAdd:false
      },
      arr:[]
    }
  },
  computed: {
    ...mapGetters({}),
  },
  mounted() {
    this.getList()
  },
  methods: {
    ...mapActions({}),
    willUpdate(id){
      this.isshow = true;
      this.isAdd = false;
      this.$refs.form.getOne(id)
    },
    getList(){
        reqrolelist().then(res => {
            // console.log(res);
            this.arr = res.data.list ? res.data.list : [];
        })
    },
    add(){
      this.info.isshow = true;
      this.info.isAdd = true;
    }
  },
};
</script>
<style scoped lang="less">
@import "../../less/index.less";
.el-button{
  margin: 20px;
}
</style>